Skip to content

Conversation

@imcraftsman
Copy link
Contributor

when we login as an ordinary client, our folders which assigned by the administrator are usually not in the webserver root directory. so, we could not get the file's hyperlink, and we could not preview pictures and appreciate video online.
but,now,the problem is solved when a proxy is added in tinyfilemanager.php.
modified items list:

  1. add a proxy;
  2. modify image's/video's hyperlinks
  3. modify file's 'direct link' related with open button.

in addition:
There is a clerical error in lin "$fileTypes['jfif'] = 'image/jpg';" it should be "$fileTypes['jfif'] = 'image/jfif';"
in my another PR(PR id= #1269)

running envirement: Android 4.4+PHP 7.4.3+ KSWEB
http://192.168.1.2/tinyfilemanager.php, afer login,the main page could not be showed entirely,it just shows half of navigation bar.

that's becuase of
there are two same lines of codes which cause the problem. they are
$owner = posix_getpwuid(fileowner($path . '/' . $f));
when the funciton fileowner($path . '/' . $f)  return 0 and  run the function posix_getpwuid(....), it trig an error.
please check the codes in line 2156--2168 and 2221--2233

suggest replace these two parts with followed  codes:
                $owner = array('name' => '?');
                $group = array('name' => '?');
                if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
                    try{
                        $owner_id = fileowner($path . '/' . $f);
                        if($owner_id != 0) {
                            $owner_info = posix_getpwuid($owner_id);
                           if ($owner_info) {
                                  $owner =  $owner_info;
                           }
                       }

                        $group_id = filegroup($path . '/' . $f);
                        $group_info = posix_getgrgid($group_id);
                        if ($group_info) {
                             $group =  $group_info;
                         }

                    } catch(Exception $e){
                       error_log("exception:" . $e->getMessage());
                    }
                }
add proxy to show image/vedio out of the webserver root directory

when we login as an ordinary client, our folders which assigned by the administrator are usually not in the webserver root directory. so, we could not get the file's hyperlink, and we could not preview our pictures and watch our video online.
now, the problem is solved. I add a proxy to settle this.
modified list:
1) add a proxy;
2) modify  image's/video's  hyperlinks
3) modify file's 'direct link' related with open button.

in addition:
There is a clerical error in lin "$fileTypes['jfif'] = 'image/jpg';" it should be "$fileTypes['jfif'] = 'image/jfif';"
in  my another PR(PR id= prasathmani#1269)
simplify the method of calling  proxy
@imcraftsman
Copy link
Contributor Author

this PR relate to these issues:
Preview images and direct links not working for user specific directories #724
#724
Cannot play mp3 #1146
#1146
File preview and opening not working. #1247
#1247

0)update from https://github.com/prasathmani/tinyfilemanager
1) modify proxy, add some codes to adapt  isset($_SERVER['HTTP_RANGE'])
2)add new function ---  album.
1) Support all paths on the OpenWrt system.
2) Send video stream with segment-by-segment
3) Reduce the creating-thumbnail function parameters
4) Change the method of creating thumbnails 
5) Add some debugging code
Added support for trusting proxy IP headers, improved client IP retrieval, and enhanced path sanitization to prevent security issues. Updated HTML generation to escape directory and file names to prevent XSS attacks.

Need to add globlal a new paramater   into config.php file
// **新增:是否信任反向代理的 IP 头 (例如 Cloudflare 或 Nginx)**
// false (默认/最安全):只使用 REMOTE_ADDR,防止 IP 伪造。
// true (使用代理时):允许读取 HTTP_X_FORWARDED_FOR 等头,获取真实客户端 IP。
$trust_proxy = false;
add config.php and favicon.ico
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant